#include "widget.h"

#include <QComboBox>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    resize(600, 480);
    QComboBox *com = new QComboBox(this);
    com->resize(200, 30);
    com->move(100, 20);

    com->addItem("北京市");
    com->addItem("上海市");
    com->addItem("重庆市");
    com->addItem("天津市");
    com->addItem("湖北省");
    com->addItem("湖南省");
    com->addItem("海南省");

    //设置下拉框的默认值
    com->setCurrentIndex(4);

    //对于信号或者槽有重载版本的时候，需要注意写法
    connect(com, QOverload<int>::of(&QComboBox::currentIndexChanged),
            [=](int idx){
        qDebug() << "idx = " << idx;
        qDebug() << "text = " << com->currentText();

    });
}

Widget::~Widget()
{
}

